<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户</title>
    <link rel="stylesheet" type="text/css" href="./easyui/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="./easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="./easyui/themes/color.css">
    <script type="text/javascript" src="./easyui/jquery.min.js"></script>
    <script type="text/javascript" src="./easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="./js/common.js"></script>
</head>
<body>
<div style="height: 270px;width: 500px;left: 50%;top: 20%;position:absolute;margin-left: -250px;">
    <div class="easyui-panel" title="注册用户" style="padding:20px;" >
        <form id="ff" method="post">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" id="username" name="username"  style="width:100%" data-options="label:'用户名:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-passwordbox" id="password" name="password"   prompt="Password" style="width:100%" iconWidth="28" data-options="label:'密码:',required:true">
            </div>
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" id="name" name="name"    style="width:100%" iconWidth="28" data-options="label:'名称:',required:true">
            </div>

            <div style="margin-bottom:20px">
                <input class="easyui-textbox" id="mailName" name="mailName"    style="width:100%" iconWidth="28" data-options="label:'邮箱名称:',required:true,validType:'email'">
            </div>

            <div style="margin-bottom:20px">
                <input class="easyui-textbox" id="mailPwd" name="mailPwd"    style="width:100%" iconWidth="28" data-options="label:'邮箱密码:',required:true">
            </div>

            <div style="margin-bottom:20px">
                <input class="easyui-textbox" id="mobile" name="mobile"    style="width:100%" iconWidth="28" data-options="label:'电话:'">
            </div>


        </form>
        <div style="text-align:center;padding:5px 0">
            <a href="javascript:void(0)" class="easyui-linkbutton" id="regist_btn" onclick="submitForm()" style="width:80px">注册</a>
        </div>
    </div>

</div>

<script>
      function submitForm1(){
        var username = $('#username').val();
        var password = $('#password').val();
        if(!username||!password){
            $.messager.alert("提示","用户名密码不能为空");
            return ;
        }
        $.cpost('user/login.do',{'username':username,'password':password},function(data){
          if(!data.result){
            $.messager.alert('提示','用户名/密码错误');
            return;
          }
            $.saveLogin(data.data);
          window.location.href="report.html"
        });
      }

      var url = 'user/add.do'
      function submitForm(){
			$('#ff').form('submit', {
                url: url,
                onSubmit: function(){
                    var isValid = $(this).form('validate');
                    if (!isValid){
                        $.messager.progress('close');
                    }
                    return isValid;
                },
                success: function(data){
                    data = JSON.parse(data);
                    if(data.code == 0){
                        window.location.href="index.html";
                        return;
                    }
                    $.messager.alert('提示',data.msg);
                }
            });
		}


    $(function(){
        var loginInfo =  $.getLogin();
        if(loginInfo != null){
            url = 'user/modify.do'
            $('#ff').form('load',loginInfo.currentUser);
            $('#username').textbox('readonly');
            $('title').html('修改个人信息');
            $('#regist_btn').html('修改');
            $('.panel-title').html('修改个人信息');
        }

        $(document).keyup(function(event){
            if(event.keyCode ==13){
                submitForm();
            }
        });
    });



    </script>
</body>
</html>